﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using ScottIsAFool;

namespace LiveWriterBackupWPF
{
	public partial class canAdvancedOptionsxaml
	{
        Blog[] _allBlogs;

		public canAdvancedOptionsxaml()
		{
			this.InitializeComponent();
            _allBlogs = WriterUtils.ConfiguredBlogs();
            SetBlogs();
            linklabelSelectAll_Click(this, null);
            lbBlogs_SelectionChanged(this, null);
        }

        private void SetBlogs()
        {
            foreach (Blog blog in _allBlogs)
            {
                ListBoxItem item = new ListBoxItem();
                item.Content = blog.Name;
                item.Tag = blog.ID;
                lbBlogs.Items.Add(item);
            }
        }

        private void linklabelSelectAll_Click(object sender, RoutedEventArgs e)
        {
            foreach (ListBoxItem item in lbBlogs.Items)
            {
                item.IsSelected = true;
            }
            lbBlogs.Focus();
        }

        private void linklabelSelectNone_Click(object sender, RoutedEventArgs e)
        {
            foreach (ListBoxItem item in lbBlogs.Items)
            {
                item.IsSelected = false;
            }
            lbBlogs.Focus();
        }

        private void lbBlogs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            labelNumberOfBlogs.Content = "Number of blogs selected: " + lbBlogs.SelectedItems.Count;
        }
	}
}